3.36 \(\int \frac{\cot ^2(c+d x) (B \tan (c+d x)+C \tan ^2(c+d x))}{(a+b \tan (c+d x))^2} \, dx\)

Optimal. Leaf size=137 \[ \frac{b (b B-a C)}{a d \left (a^2+b^2\right ) (a+b \tan (c+d x))}-\frac{b \left (3 a^2 b B-2 a^3 C+b^3 B\right ) \log (a \cos (c+d x)+b \sin (c+d x))}{a^2 d \left (a^2+b^2\right )^2}-\frac{x \left (a^2 (-C)+2 a b B+b^2 C\right )}{\left (a^2+b^2\right )^2}+\frac{B \log (\sin (c+d x))}{a^2 d} \]

[Out]

-(((2*a*b*B - a^2*C + b^2*C)*x)/(a^2 + b^2)^2) + (B*Log[Sin[c + d*x]])/(a^2*d) - (b*(3*a^2*b*B + b^3*B - 2*a^3
*C)*Log[a*Cos[c + d*x] + b*Sin[c + d*x]])/(a^2*(a^2 + b^2)^2*d) + (b*(b*B - a*C))/(a*(a^2 + b^2)*d*(a + b*Tan[
c + d*x]))

________________________________________________________________________________________

Rubi [A]  time = 0.402681, antiderivative size = 137, normalized size of antiderivative = 1., number of steps used = 5, number of rules used = 5, integrand size = 40, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.125, Rules used = {3632, 3609, 3651, 3530, 3475} \[ \frac{b (b B-a C)}{a d \left (a^2+b^2\right ) (a+b \tan (c+d x))}-\frac{b \left (3 a^2 b B-2 a^3 C+b^3 B\right ) \log (a \cos (c+d x)+b \sin (c+d x))}{a^2 d \left (a^2+b^2\right )^2}-\frac{x \left (a^2 (-C)+2 a b B+b^2 C\right )}{\left (a^2+b^2\right )^2}+\frac{B \log (\sin (c+d x))}{a^2 d} \]

Antiderivative was successfully verified.

[In]

Int[(Cot[c + d*x]^2*(B*Tan[c + d*x] + C*Tan[c + d*x]^2))/(a + b*Tan[c + d*x])^2,x]

[Out]

-(((2*a*b*B - a^2*C + b^2*C)*x)/(a^2 + b^2)^2) + (B*Log[Sin[c + d*x]])/(a^2*d) - (b*(3*a^2*b*B + b^3*B - 2*a^3
*C)*Log[a*Cos[c + d*x] + b*Sin[c + d*x]])/(a^2*(a^2 + b^2)^2*d) + (b*(b*B - a*C))/(a*(a^2 + b^2)*d*(a + b*Tan[
c + d*x]))

Rule 3632

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])^(n_.)*((A_.) + (B_.)
*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> Dist[1/b^2, Int[(a + b*Tan[e + f*x])
^(m + 1)*(c + d*Tan[e + f*x])^n*(b*B - a*C + b*C*Tan[e + f*x]), x], x] /; FreeQ[{a, b, c, d, e, f, A, B, C, m,
 n}, x] && NeQ[b*c - a*d, 0] && EqQ[A*b^2 - a*b*B + a^2*C, 0]

Rule 3609

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e
_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[(b*(A*b - a*B)*(a + b*Tan[e + f*x])^(m + 1)*(c + d*Tan[e + f*x])^(n
 + 1))/(f*(m + 1)*(b*c - a*d)*(a^2 + b^2)), x] + Dist[1/((m + 1)*(b*c - a*d)*(a^2 + b^2)), Int[(a + b*Tan[e +
f*x])^(m + 1)*(c + d*Tan[e + f*x])^n*Simp[b*B*(b*c*(m + 1) + a*d*(n + 1)) + A*(a*(b*c - a*d)*(m + 1) - b^2*d*(
m + n + 2)) - (A*b - a*B)*(b*c - a*d)*(m + 1)*Tan[e + f*x] - b*d*(A*b - a*B)*(m + n + 2)*Tan[e + f*x]^2, x], x
], x] /; FreeQ[{a, b, c, d, e, f, A, B, n}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && NeQ[c^2 + d^2, 0]
&& LtQ[m, -1] && (IntegerQ[m] || IntegersQ[2*m, 2*n]) &&  !(ILtQ[n, -1] && ( !IntegerQ[m] || (EqQ[c, 0] && NeQ
[a, 0])))

Rule 3651

Int[((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (f_.)*(x_)]^2)/(((a_) + (b_.)*tan[(e_.) + (f_.)
*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])), x_Symbol] :> Simp[((a*(A*c - c*C + B*d) + b*(B*c - A*d + C*d
))*x)/((a^2 + b^2)*(c^2 + d^2)), x] + (Dist[(A*b^2 - a*b*B + a^2*C)/((b*c - a*d)*(a^2 + b^2)), Int[(b - a*Tan[
e + f*x])/(a + b*Tan[e + f*x]), x], x] - Dist[(c^2*C - B*c*d + A*d^2)/((b*c - a*d)*(c^2 + d^2)), Int[(d - c*Ta
n[e + f*x])/(c + d*Tan[e + f*x]), x], x]) /; FreeQ[{a, b, c, d, e, f, A, B, C}, x] && NeQ[b*c - a*d, 0] && NeQ
[a^2 + b^2, 0] && NeQ[c^2 + d^2, 0]

Rule 3530

Int[((c_) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(c*Log[Re
moveContent[a*Cos[e + f*x] + b*Sin[e + f*x], x]])/(b*f), x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d,
0] && NeQ[a^2 + b^2, 0] && EqQ[a*c + b*d, 0]

Rule 3475

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> -Simp[Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rubi steps

\begin{align*} \int \frac{\cot ^2(c+d x) \left (B \tan (c+d x)+C \tan ^2(c+d x)\right )}{(a+b \tan (c+d x))^2} \, dx &=\int \frac{\cot (c+d x) (B+C \tan (c+d x))}{(a+b \tan (c+d x))^2} \, dx\\ &=\frac{b (b B-a C)}{a \left (a^2+b^2\right ) d (a+b \tan (c+d x))}+\frac{\int \frac{\cot (c+d x) \left (\left (a^2+b^2\right ) B-a (b B-a C) \tan (c+d x)+b (b B-a C) \tan ^2(c+d x)\right )}{a+b \tan (c+d x)} \, dx}{a \left (a^2+b^2\right )}\\ &=-\frac{\left (2 a b B-a^2 C+b^2 C\right ) x}{\left (a^2+b^2\right )^2}+\frac{b (b B-a C)}{a \left (a^2+b^2\right ) d (a+b \tan (c+d x))}+\frac{B \int \cot (c+d x) \, dx}{a^2}-\frac{\left (b \left (3 a^2 b B+b^3 B-2 a^3 C\right )\right ) \int \frac{b-a \tan (c+d x)}{a+b \tan (c+d x)} \, dx}{a^2 \left (a^2+b^2\right )^2}\\ &=-\frac{\left (2 a b B-a^2 C+b^2 C\right ) x}{\left (a^2+b^2\right )^2}+\frac{B \log (\sin (c+d x))}{a^2 d}-\frac{b \left (3 a^2 b B+b^3 B-2 a^3 C\right ) \log (a \cos (c+d x)+b \sin (c+d x))}{a^2 \left (a^2+b^2\right )^2 d}+\frac{b (b B-a C)}{a \left (a^2+b^2\right ) d (a+b \tan (c+d x))}\\ \end{align*}

Mathematica [C]  time = 2.36069, size = 159, normalized size = 1.16 \[ -\frac{\frac{2 b (a C-b B)}{a \left (a^2+b^2\right ) (a+b \tan (c+d x))}+\frac{2 b \left (3 a^2 b B-2 a^3 C+b^3 B\right ) \log (a+b \tan (c+d x))}{a^2 \left (a^2+b^2\right )^2}-\frac{2 B \log (\tan (c+d x))}{a^2}+\frac{(B+i C) \log (-\tan (c+d x)+i)}{(a+i b)^2}+\frac{(B-i C) \log (\tan (c+d x)+i)}{(a-i b)^2}}{2 d} \]

Antiderivative was successfully verified.

[In]

Integrate[(Cot[c + d*x]^2*(B*Tan[c + d*x] + C*Tan[c + d*x]^2))/(a + b*Tan[c + d*x])^2,x]

[Out]

-(((B + I*C)*Log[I - Tan[c + d*x]])/(a + I*b)^2 - (2*B*Log[Tan[c + d*x]])/a^2 + ((B - I*C)*Log[I + Tan[c + d*x
]])/(a - I*b)^2 + (2*b*(3*a^2*b*B + b^3*B - 2*a^3*C)*Log[a + b*Tan[c + d*x]])/(a^2*(a^2 + b^2)^2) + (2*b*(-(b*
B) + a*C))/(a*(a^2 + b^2)*(a + b*Tan[c + d*x])))/(2*d)

________________________________________________________________________________________

Maple [B]  time = 0.148, size = 325, normalized size = 2.4 \begin{align*} -{\frac{\ln \left ( 1+ \left ( \tan \left ( dx+c \right ) \right ) ^{2} \right ){a}^{2}B}{2\,d \left ({a}^{2}+{b}^{2} \right ) ^{2}}}+{\frac{\ln \left ( 1+ \left ( \tan \left ( dx+c \right ) \right ) ^{2} \right ){b}^{2}B}{2\,d \left ({a}^{2}+{b}^{2} \right ) ^{2}}}-{\frac{\ln \left ( 1+ \left ( \tan \left ( dx+c \right ) \right ) ^{2} \right ) Cab}{d \left ({a}^{2}+{b}^{2} \right ) ^{2}}}-2\,{\frac{B\arctan \left ( \tan \left ( dx+c \right ) \right ) ab}{d \left ({a}^{2}+{b}^{2} \right ) ^{2}}}+{\frac{C\arctan \left ( \tan \left ( dx+c \right ) \right ){a}^{2}}{d \left ({a}^{2}+{b}^{2} \right ) ^{2}}}-{\frac{C\arctan \left ( \tan \left ( dx+c \right ) \right ){b}^{2}}{d \left ({a}^{2}+{b}^{2} \right ) ^{2}}}+{\frac{B\ln \left ( \tan \left ( dx+c \right ) \right ) }{{a}^{2}d}}+{\frac{{b}^{2}B}{ad \left ({a}^{2}+{b}^{2} \right ) \left ( a+b\tan \left ( dx+c \right ) \right ) }}-{\frac{Cb}{d \left ({a}^{2}+{b}^{2} \right ) \left ( a+b\tan \left ( dx+c \right ) \right ) }}-3\,{\frac{\ln \left ( a+b\tan \left ( dx+c \right ) \right ){b}^{2}B}{d \left ({a}^{2}+{b}^{2} \right ) ^{2}}}-{\frac{{b}^{4}\ln \left ( a+b\tan \left ( dx+c \right ) \right ) B}{d \left ({a}^{2}+{b}^{2} \right ) ^{2}{a}^{2}}}+2\,{\frac{\ln \left ( a+b\tan \left ( dx+c \right ) \right ) Cab}{d \left ({a}^{2}+{b}^{2} \right ) ^{2}}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(cot(d*x+c)^2*(B*tan(d*x+c)+C*tan(d*x+c)^2)/(a+b*tan(d*x+c))^2,x)

[Out]

-1/2/d/(a^2+b^2)^2*ln(1+tan(d*x+c)^2)*a^2*B+1/2/d/(a^2+b^2)^2*ln(1+tan(d*x+c)^2)*b^2*B-1/d/(a^2+b^2)^2*ln(1+ta
n(d*x+c)^2)*C*a*b-2/d/(a^2+b^2)^2*B*arctan(tan(d*x+c))*a*b+1/d/(a^2+b^2)^2*C*arctan(tan(d*x+c))*a^2-1/d/(a^2+b
^2)^2*C*arctan(tan(d*x+c))*b^2+1/d/a^2*B*ln(tan(d*x+c))+1/d*b^2/a/(a^2+b^2)/(a+b*tan(d*x+c))*B-1/d*b/(a^2+b^2)
/(a+b*tan(d*x+c))*C-3/d/(a^2+b^2)^2*ln(a+b*tan(d*x+c))*b^2*B-1/d*b^4/(a^2+b^2)^2/a^2*ln(a+b*tan(d*x+c))*B+2/d/
(a^2+b^2)^2*ln(a+b*tan(d*x+c))*C*a*b

________________________________________________________________________________________

Maxima [A]  time = 1.63628, size = 281, normalized size = 2.05 \begin{align*} \frac{\frac{2 \,{\left (C a^{2} - 2 \, B a b - C b^{2}\right )}{\left (d x + c\right )}}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} + \frac{2 \,{\left (2 \, C a^{3} b - 3 \, B a^{2} b^{2} - B b^{4}\right )} \log \left (b \tan \left (d x + c\right ) + a\right )}{a^{6} + 2 \, a^{4} b^{2} + a^{2} b^{4}} - \frac{{\left (B a^{2} + 2 \, C a b - B b^{2}\right )} \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} - \frac{2 \,{\left (C a b - B b^{2}\right )}}{a^{4} + a^{2} b^{2} +{\left (a^{3} b + a b^{3}\right )} \tan \left (d x + c\right )} + \frac{2 \, B \log \left (\tan \left (d x + c\right )\right )}{a^{2}}}{2 \, d} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(cot(d*x+c)^2*(B*tan(d*x+c)+C*tan(d*x+c)^2)/(a+b*tan(d*x+c))^2,x, algorithm="maxima")

[Out]

1/2*(2*(C*a^2 - 2*B*a*b - C*b^2)*(d*x + c)/(a^4 + 2*a^2*b^2 + b^4) + 2*(2*C*a^3*b - 3*B*a^2*b^2 - B*b^4)*log(b
*tan(d*x + c) + a)/(a^6 + 2*a^4*b^2 + a^2*b^4) - (B*a^2 + 2*C*a*b - B*b^2)*log(tan(d*x + c)^2 + 1)/(a^4 + 2*a^
2*b^2 + b^4) - 2*(C*a*b - B*b^2)/(a^4 + a^2*b^2 + (a^3*b + a*b^3)*tan(d*x + c)) + 2*B*log(tan(d*x + c))/a^2)/d

________________________________________________________________________________________

Fricas [B]  time = 1.35152, size = 701, normalized size = 5.12 \begin{align*} -\frac{2 \, C a^{2} b^{3} - 2 \, B a b^{4} - 2 \,{\left (C a^{5} - 2 \, B a^{4} b - C a^{3} b^{2}\right )} d x -{\left (B a^{5} + 2 \, B a^{3} b^{2} + B a b^{4} +{\left (B a^{4} b + 2 \, B a^{2} b^{3} + B b^{5}\right )} \tan \left (d x + c\right )\right )} \log \left (\frac{\tan \left (d x + c\right )^{2}}{\tan \left (d x + c\right )^{2} + 1}\right ) -{\left (2 \, C a^{4} b - 3 \, B a^{3} b^{2} - B a b^{4} +{\left (2 \, C a^{3} b^{2} - 3 \, B a^{2} b^{3} - B b^{5}\right )} \tan \left (d x + c\right )\right )} \log \left (\frac{b^{2} \tan \left (d x + c\right )^{2} + 2 \, a b \tan \left (d x + c\right ) + a^{2}}{\tan \left (d x + c\right )^{2} + 1}\right ) - 2 \,{\left (C a^{3} b^{2} - B a^{2} b^{3} +{\left (C a^{4} b - 2 \, B a^{3} b^{2} - C a^{2} b^{3}\right )} d x\right )} \tan \left (d x + c\right )}{2 \,{\left ({\left (a^{6} b + 2 \, a^{4} b^{3} + a^{2} b^{5}\right )} d \tan \left (d x + c\right ) +{\left (a^{7} + 2 \, a^{5} b^{2} + a^{3} b^{4}\right )} d\right )}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(cot(d*x+c)^2*(B*tan(d*x+c)+C*tan(d*x+c)^2)/(a+b*tan(d*x+c))^2,x, algorithm="fricas")

[Out]

-1/2*(2*C*a^2*b^3 - 2*B*a*b^4 - 2*(C*a^5 - 2*B*a^4*b - C*a^3*b^2)*d*x - (B*a^5 + 2*B*a^3*b^2 + B*a*b^4 + (B*a^
4*b + 2*B*a^2*b^3 + B*b^5)*tan(d*x + c))*log(tan(d*x + c)^2/(tan(d*x + c)^2 + 1)) - (2*C*a^4*b - 3*B*a^3*b^2 -
 B*a*b^4 + (2*C*a^3*b^2 - 3*B*a^2*b^3 - B*b^5)*tan(d*x + c))*log((b^2*tan(d*x + c)^2 + 2*a*b*tan(d*x + c) + a^
2)/(tan(d*x + c)^2 + 1)) - 2*(C*a^3*b^2 - B*a^2*b^3 + (C*a^4*b - 2*B*a^3*b^2 - C*a^2*b^3)*d*x)*tan(d*x + c))/(
(a^6*b + 2*a^4*b^3 + a^2*b^5)*d*tan(d*x + c) + (a^7 + 2*a^5*b^2 + a^3*b^4)*d)

________________________________________________________________________________________

Sympy [F(-2)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: AttributeError} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(cot(d*x+c)**2*(B*tan(d*x+c)+C*tan(d*x+c)**2)/(a+b*tan(d*x+c))**2,x)

[Out]

Exception raised: AttributeError

________________________________________________________________________________________

Giac [B]  time = 1.8665, size = 377, normalized size = 2.75 \begin{align*} \frac{\frac{2 \,{\left (C a^{2} - 2 \, B a b - C b^{2}\right )}{\left (d x + c\right )}}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} - \frac{{\left (B a^{2} + 2 \, C a b - B b^{2}\right )} \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} + \frac{2 \,{\left (2 \, C a^{3} b^{2} - 3 \, B a^{2} b^{3} - B b^{5}\right )} \log \left ({\left | b \tan \left (d x + c\right ) + a \right |}\right )}{a^{6} b + 2 \, a^{4} b^{3} + a^{2} b^{5}} + \frac{2 \, B \log \left ({\left | \tan \left (d x + c\right ) \right |}\right )}{a^{2}} - \frac{2 \,{\left (2 \, C a^{3} b^{2} \tan \left (d x + c\right ) - 3 \, B a^{2} b^{3} \tan \left (d x + c\right ) - B b^{5} \tan \left (d x + c\right ) + 3 \, C a^{4} b - 4 \, B a^{3} b^{2} + C a^{2} b^{3} - 2 \, B a b^{4}\right )}}{{\left (a^{6} + 2 \, a^{4} b^{2} + a^{2} b^{4}\right )}{\left (b \tan \left (d x + c\right ) + a\right )}}}{2 \, d} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(cot(d*x+c)^2*(B*tan(d*x+c)+C*tan(d*x+c)^2)/(a+b*tan(d*x+c))^2,x, algorithm="giac")

[Out]

1/2*(2*(C*a^2 - 2*B*a*b - C*b^2)*(d*x + c)/(a^4 + 2*a^2*b^2 + b^4) - (B*a^2 + 2*C*a*b - B*b^2)*log(tan(d*x + c
)^2 + 1)/(a^4 + 2*a^2*b^2 + b^4) + 2*(2*C*a^3*b^2 - 3*B*a^2*b^3 - B*b^5)*log(abs(b*tan(d*x + c) + a))/(a^6*b +
 2*a^4*b^3 + a^2*b^5) + 2*B*log(abs(tan(d*x + c)))/a^2 - 2*(2*C*a^3*b^2*tan(d*x + c) - 3*B*a^2*b^3*tan(d*x + c
) - B*b^5*tan(d*x + c) + 3*C*a^4*b - 4*B*a^3*b^2 + C*a^2*b^3 - 2*B*a*b^4)/((a^6 + 2*a^4*b^2 + a^2*b^4)*(b*tan(
d*x + c) + a)))/d